<template>
  <div class="app-container">
    <!-- 查询表单 -->
    <el-form :model="query" ref="queryRef" :inline="true" size="small">
      <el-form-item label="关键字">
        <el-input v-model="query.keyword"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery">查询</el-button>
      </el-form-item>
    </el-form>
    <!-- 数据表格 -->
    <el-table :data="list" border stripe>
      <el-table-column label="#" type="index" />
      <el-table-column label="姓名" prop="name" />
      <el-table-column label="手机" prop="mobile" />
      <el-table-column label="身份证号" prop="idCard">
        <template slot-scope="{ row }">
          {{ row.idCard !== '0'  ? row.idCard : '-'}}
        </template>
      </el-table-column>
      <el-table-column label="性别" prop="sex" />
      <el-table-column label="年龄" prop="age" />
      <el-table-column label="是否结婚" prop="marry">
        <template slot-scope="{ row }">
          {{ row.marry ? '是' : '否' }}
        </template>
      </el-table-column>
      <el-table-column label="状态" prop="status">
        <template slot-scope="{ row }">
          {{ row.status === 0 ? '未认证' : row.status === 1 ? '认证中' : row.status === 2 ? '认证通过' : '认证失败'}}
        </template>
      </el-table-column>
      <el-table-column label="申请时间" prop="createTime" />
      <el-table-column label="操作">
        <template slot-scope="{ row }">
          <el-button v-if="row.status === 1" type="info" size="mini" @click="handleApproval(row.id)"
            >审批</el-button
          >
          <el-button  v-if="row.status === 2"  type="primary" size="mini" @click="handleApproval(row.id)"
            >查看</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <page-complete :total="total" @change="pageChange"/>
    
  </div>
</template>

<script>
import PageComplete from '@/components/PageComplete'
import commonApi from '@/api/common'
import getQueryListGetMix from '@/mixins/getQueryListGetMix'
export default {
  name: 'borrowerList',
  components: {
    PageComplete,
  },
  data() {
    return {
      apiName: '/admin/core/borrower',
      queryPageListGet: commonApi.queryPageListGet,
      list: [],
      total: 0,
      query: {
        page: 1,
        limit: 2,
        keyword: '',
      },

    }
  },
  mixins: [getQueryListGetMix],
  created() {
    this.getQueryPageList(this.apiName, this.query)
  },
  methods: {
    pageChange({page,limit}) {
      this.query.page = page
      this.query.limit = limit
      this.getQueryPageList(this.apiName, this.query)
    },
    handleQuery() {
      this.query.page = 1
      this.getQueryPageList(this.apiName, this.query)
    },
    handleApproval(id) {
      this.$router.push({
        path: './detail',
        query:{id}
      })
    }
  },
}
</script>

<style lang="scss" scoped>
</style>